//1154. 一年中的第几天

#include <string>
using namespace std;

class Solution {
public:
    int dayOfYear(string date) {
        int monthArray[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
        int year = stoi(date.substr(0, 4));
        int month = stoi(date.substr(5, 2));
        int day = stoi(date.substr(8, 2));

        if((year%4 == 0 && year%100 != 0) || year%400 == 0)
            monthArray[2]++;

        int days = 0;
        for(int i = 0; i < month; i++)
        {
            days += monthArray[i];
        }
        days += day;

        return days;
    }
};